﻿@model List<OrderHistory>
@{
    ViewBag.Title = "Order History";
    string contactEmail = System.Configuration.ConfigurationManager.AppSettings["ContactEmail"];
}

@if (Model.Count > 0)
{
    <p>Below are the orders you have previously placed. For any questions about past orders or billing, please contact <a href="mailto:@contactEmail">@contactEmail</a>.</p>
    <table class="med">
        <thead>
            <tr>
                <th>Date</th>
                <th>Total Cost</th>
                <th>Items</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var order in Model)
            {
                <tr>
                    <td>@order.DatePosted</td>
                    <td>@String.Format("{0:c}", order.TotalCost)</td>
                    <td>
                        <ul class="orderHist">
                            @foreach (var p in order.Products)
                            {
                                <li>@p.LinkToItem(Html, p.Title)</li>
                            }
                        </ul>
                    </td>
                </tr>
            }
        </tbody>
    </table>
}
else
{
    <p>Our records indicate that there has been no orders placed for this account. For any questions about past orders or billing, please contact <a href="mailto:@contactEmail">@contactEmail</a>.</p>
}
<p>@Html.ActionLink("Back to My Training", "Index")</p>
